import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { knowledge, resource, system } from '@/api/apiModulesType';

// 加入收藏
export function apiFilesCollectionAddCollection(data) {
  return request({
    url: `${knowledge}/filesCollection/addCollection`,
    method: 'post',
    data
  });
}

// 取消收藏
export function apiFilesCollectionCancelCollection(data) {
  return request({
    url: `${knowledge}/filesCollection/cancelCollection`,
    method: 'post',
    data
  });
}
// 新建文件夹
export function apiFilesTreeAddFolder(data) {
  return request({
    url: `${knowledge}/api/teamFilesTree/addFolder`,
    method: 'post',
    data
  });
}
//查询左边树-新的,只有文件夹
export function apiTreeFileSelectTree(params) {
  return request({
    url: `${knowledge}/api/teamFilesTree/selectTree`,
    method: 'get',
    params
  });
}
//查询右边表格-分页
export function apiTreeFileSelectTreePage(params) {
  return request({
    url: `${knowledge}/api/teamFilesTree/selectTreePage`,
    method: 'get',
    params
  });
}
//移动 文件
export function apiFilesTreeMove(data) {
  return request({
    url: `${knowledge}/api/teamFilesTree/fileTreeMove`,
    method: 'post',
    data
  });
}

// 复制文件
export function apiFilesTreeCopy(data) {
  return request({
    url: `${knowledge}/api/teamFilesTree/treeCopy`,
    method: 'post',
    data
  });
}
// 文件:跳转树目录---用于搜索出来点文件获取树结构信息
export function ApiPerTreeNodeAll(params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/unifiedCollection/new/getParentTreeNodeAll`,
    params: params
  });
}
// 修改文件名称
export function ApiPerUpdateName(data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/teamFilesTree/rename`,
    data: data
  });
}
// 打印
export const apiOnlinePrint = function (data?: any) {
  return request({
    method: 'post',
    url: `/${resource}/oss/file/date/print`,
    data: data,
    responseType: 'arraybuffer'
  });
};
//文档:删除
export const ApiPerDelFile = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/recycleBin/removeFile`,
    params: params
  });
};
// 分发
export const ApiPerFilesDistribute = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesDistribute`,
    data: data
  });
};
// 提交到企业库
export function apiFilesTreeCommitEnterprise(params) {
  return request({
    url: `${knowledge}/api/teamFilesTree/commitEnterprise`,
    method: "get",
    params
  });
}
// 置顶
export function apiTreeFileTop(data) {
  return request({
    url: `${knowledge}/api/teamFilesTree/top`,
    method: "post",
    data
  });
}
// 加入订阅
export function apiFileAttentionAddAttention(data) {
  return request({
    url: `${knowledge}/fileAttention/addAttention`,
    method: "post",
    data
  });
}

// 取消订阅
export function apiFileAttentionCancelAttention(data) {
  return request({
    url: `${knowledge}/fileAttention/cancelAttention`,
    method: "post",
    data
  });
}
//查询团队文档权限 - 查询该文件的团队成员
export function apiTeamRelevanceRoleQuery(params) {
	return request({
		url: `${knowledge}/api/teamRelevanceRole/query`,
		method: 'get',
		params
	})
}

export default {
  apiFilesCollectionAddCollection,
  apiFilesCollectionCancelCollection,
  apiFilesTreeAddFolder,
  apiTreeFileSelectTree,
  apiTreeFileSelectTreePage,
  apiFilesTreeMove,
  apiFilesTreeCopy,
  ApiPerTreeNodeAll,
  ApiPerUpdateName,
  apiOnlinePrint,
  ApiPerDelFile,
  ApiPerFilesDistribute,
  apiFilesTreeCommitEnterprise,
  apiTreeFileTop,
  apiFileAttentionAddAttention,
  apiFileAttentionCancelAttention,
  apiTeamRelevanceRoleQuery
};
